home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / misc / DReg.lha / DReg / DReg.a < prev    next >
Text File  |  1999-02-01  |  21KB  |  545 lines

  1.  
  2.  
  3. *************************************************************************
  4. *                                                                       *
  5. *       dreg.a   v1.21   -   A68k Data Register Processor               *
  6. *                                                                       *
  7. *       started:    24-jun-93                                           *
  8. *       updates:    26-jul-93   iconize gadget added                    *
  9. *                   22-mar-93   AutoStartup code added                  *
  10. *                    1-feb-99   Corrected Enforcer hit                  *
  11. *                               (as suggested by Thomas Bieg)           *
  12. *                                                                       *
  13. *       Assembled using Devpac v3.02 and system.gs                      *
  14. *                                                                       *
  15. *                                                                       *
  16. *************************************************************************
  17. *
  18.  
  19.             opt     d-,s-,o+,w+
  20.  
  21. *            include     graphics/graphics_lib.i
  22. *            include     intuition/intuition.i
  23. *            include     intuition/intuition_lib.i
  24. *            include     exec/exec.i
  25.             include     exec/execbase.i
  26. *            include     exec/exec_lib.i
  27. *            include     libraries/dosextens.i
  28. *            include     libraries/dos_lib.i
  29. *            include     libraries/arpbase.i
  30.             include     launch.i
  31.  
  32.  
  33. *       Open the graphics & intuition libraries,
  34. *           then open a window and change it's title and colours
  35.  
  36.  
  37. regi_main:  move.l  _SysBase,a6
  38.             lea.l   gfxname,a1              graphics library
  39.             moveq.l #0,d0
  40.             jsr     _LVOOpenLibrary(a6)
  41.             move.l  d0,gfxBase              store the pointer
  42.             beq     .NoGfx                  if library found, else exit
  43.  
  44.             lea.l   intuiname,a1            try for intuition library
  45.             moveq.l #0,d0
  46.             jsr     _LVOOpenLibrary(a6)
  47.             move.l  d0,intuitionBase        store the pointer
  48.             beq.s   .NoInt                      if library found, else exit
  49.  
  50.             movea.l gfxBase,a6              a6 <- is grafixbase
  51.             lea.l   RegFntFont,a1           the included small font
  52.             jsr     _LVOAddFont(a6)         set up the small font
  53.  
  54.             move.l  _SysBase,a6
  55.             move.w  SoftVer(a6),d0          pick up KS version from exec
  56.             cmpi.w  #34,d0
  57.             ble.s   .sho_up                 pass if old WB...
  58.             bsr     mod_colrs               Set up colours for WB 2.xx
  59. .sho_up:    bsr     put_windo
  60.             tst.l   d0
  61.             beq.s   .NoWin
  62.  
  63. *       All ready to roll...
  64.  
  65.             bsr     put_panel               first put up the panel
  66.             bsr     bit_proc           <--  DO THE MAIN JOB...
  67.             cmpi.w  #300,d7                 until the ICONIZE gadget or
  68.             bne.s   .quits                  CLOSE gadget was pressed
  69.  
  70. .iconize:   bsr     wndw_icon               change window -> icon
  71.             tst.l   d0                      if not possible...
  72.             beq.s   .sho_up                     ...then replace window
  73.             bsr.s   icon_proc               wait for icon messages
  74.             bsr     icon_close                  close icon
  75.             bra.s   .sho_up                        and replace window
  76.  
  77.  
  78. *       when we get here, the 'CLOSE GADGET' was pressed...
  79.  
  80. .quits:     movea.l intuitionBase,a6        a6 <- is intuibase
  81.             move.l  regwindow,a0            ...we can quit now, but
  82.             beq.s   .NoWin
  83.             jsr     _LVOCloseWindow(a6)         first close the window
  84. .NoWin:     movea.l gfxBase,a6              a6 <- is grafixbase
  85.             lea.l   RegFntFont,a1
  86.             jsr     _LVORemFont(a6)
  87.             move.l  _SysBase,a6
  88.             move.l  intuitionBase,a1
  89.             jsr     _LVOCloseLibrary(a6)    close the intuition library...
  90. .NoInt:     move.l  gfxBase,a1
  91.             jsr     _LVOCloseLibrary(a6)        and the graphics library...
  92. .NoGfx:     clr.l   d0
  93.             rts                                     ...byeeee
  94.  
  95.  
  96.  
  97. *****************************************************************************
  98. *
  99. *               S U B R O U T I N E S
  100. *
  101. *****************************************************************************
  102. *
  103. *       Wait for the iconized DReg to be activated
  104. *       Inputs:     a4 <- pointer to window structure
  105.  
  106.  
  107. icon_proc:  bsr.s   wait_sig
  108. .button:    cmpi.l  #MOUSEBUTTONS,d6        was a button pressed ?
  109.             bne.s   .nxt_mesg               either get next message
  110.             cmpi.w  #MENUUP,d5              or was it right button ?
  111.             beq.s   .ip_ex                     YES - so un-iconize!
  112. .nxt_mesg:  bsr.s   get_mesg
  113.             bra.s   .button
  114. .ip_ex:     rts                                     and go back
  115.  
  116.  
  117. *****************************************************************************
  118. *
  119. *       Wait for a signal and return any messages
  120. *       Inputs:     a4 <- pointer to window structure
  121.  
  122.  
  123. wait_sig:   move.l  wd_UserPort(a4),a0      find window's user port address
  124.             move.b  MP_SIGBIT(a0),d7        d7<-number of message signal
  125.             moveq.l #1,d0
  126.             lsl.l   d7,d0                   d0<-calculate signal value
  127.             jsr     _LVOWait(a6)            and wait until signal occurs
  128.  
  129. get_mesg:   move.l  wd_UserPort(a4),a0      find window's user port address
  130.             jsr     _LVOGetMsg(a6)
  131.             tst.l   d0
  132.             beq.s   wait_sig                no messages, wait for next sig
  133.  
  134.             move.l  d0,a1                       else store it...
  135.             move.l  im_Class(a1),d6         d6<-IDCMPFlags
  136.             move.w  im_Code(a1),d5          d5<-IDCMPCodes
  137.             movea.l im_IAddress(a1),a3      a3<-pointer to gadget struct
  138.             jsr     _LVOReplyMsg(a6)              ...and reply to it
  139.             rts
  140.  
  141.  
  142. *****************************************************************************
  143. *
  144. *       This is the main event polling routine
  145. *       Inputs:     a4 <- pointer to window structure
  146. *       Outputs:    d7 <- gadget id - exit only for ICONIZE or CLOSE gads
  147.  
  148.  
  149. bit_proc:   movem.l a6,-(sp)
  150.             bsr.s   wait_sig
  151.  
  152. .button:    cmpi.l  #CLOSEWINDOW,d6
  153.             beq.s   .bp_ex                 finished for now, close...
  154.             cmpi.l  #GADGETDOWN,d6
  155.             beq.s   .gad_dwn
  156.             cmpi.l  #GADGETUP,d6            check for nw_IDCMPFlags
  157.             beq.s   .gad_up
  158. .get_mesg:  bsr.s   get_mesg
  159.             bra.s   .button
  160.  
  161.  
  162. *       check out the relverify gadgets
  163.  
  164. .gad_up:    move.w  gg_GadgetID(a3),d7      d7<-which gadget ?
  165.             cmpi.w  #80,d7
  166.             blt.s   .get_mesg
  167.             cmpi.w  #81,d7                  the register select gadgets
  168.             bgt.s   .filter
  169.             move.w  #numregs-1,d6           d6<- cycling d0-d4 (d7)
  170.             bsr     reg_cycle               dealing with 80 - 81
  171. .filter:    cmpi.w  #900,d7
  172.             bmi.s   .chk_icg
  173.             bsr     do_about                ABOUT gadget - do the thing
  174. .chk_icg:   cmpi.w  #300,d7                 the Iconize gadget
  175.             beq.s   .bp_ex                     so exit
  176.             cmpi.w  #200,d7
  177.             bmi.s   .get_mesg
  178.             cmpi.w  #223,d7                 filter out 200 - 223
  179.             beq.s   .dec_hex                     223 is HEX/DEC toggle !!
  180.             bpl.s   .get_mesg
  181.             bsr     processit               they are the ops gadgets
  182.             bra.s   .get_mesg                           and carry on...
  183. .dec_hex:   bsr.s   tog_disp                switch between displays
  184.             bra.s   .get_mesg                           and carry on...
  185.  
  186.  
  187. *       got an immediate gadget,  0 to 71, 90 to 92, 200 to 250
  188.  
  189. .gad_dwn:   move.w  gg_GadgetID(a3),d7      d7<-which gadget ?
  190.             cmpi.w  #90,d7                  filter out 90 to 92
  191.             bmi.s   .modbits
  192.             cmpi.w  #92,d7
  193.             bgt.s   .modbits
  194.             bsr     one_only                opsize specifier selected
  195. .modbits:   cmpi.w  #72,d7
  196.             bgt.s   .get_mesg                   and carry on...
  197.             bsr     dat_disp                deal with data & display
  198.             bra.s   .get_mesg                   and carry on...
  199.  
  200. .bp_ex:     movem.l (sp)+,a6
  201.             rts
  202.  
  203.  
  204. *****************************************************************************
  205. *
  206. *       Cycle through HEX or DECimal display
  207.  
  208.  
  209. tog_disp:   movea.l intuitionBase,a6        a6<-using intuition library
  210.             lea.l   TxtINPUT,a0
  211.             lea.l   HexDec,a1
  212.             move.w  dispsel,d1
  213.             eori.w  #$0004,d1               toggle HEX or DECimal display
  214.             move.w  d1,dispsel
  215.             move.l  (a1,d1),d0              pick up the HEX or DEC string
  216.             move.l  d0,(a0)                     tie it to the gadget
  217.             moveq.l #1,d0                       ...and refresh it
  218.             bsr     gad_refrsh
  219.             bsr     displ_val
  220. .td_ex:     move.l  _SysBase,a6             a6 <- SysBase for Mesg
  221.             rts
  222.  
  223.  
  224. *****************************************************************************
  225. *
  226. *       It's Workbench 2.xx - so change the colours
  227. *       input:      none
  228.  
  229.  
  230. bar_gadg:   move.w  d0,gg_LeftEdge(a3)
  231.             move.w  d1,gg_Height(a3)
  232.             move.l  d2,gg_GadgetRender(a3)
  233.             move.l  d3,gg_SelectRender(a3)
  234.             rts
  235.  
  236. mod_colrs:  movem.l a3-a4,-(sp)
  237.             lea.l   ImageBit0,a0
  238.             move.l  #ImageDat2Bit0,d0       the new zero image
  239.             move.l  d0,ig_ImageData(a0)
  240.             add.w   #36,d0                      and the new one image
  241.             adda.w  #20,a0
  242.             move.l  d0,ig_ImageData(a0)     this re-maps the bit colours
  243.             moveq.w #0,d0                   colour for backgroundfill
  244.             move.w  d0,wflood
  245.  
  246.             lea.l   Iconizer,a3
  247.             move.w  gg_LeftEdge(a3),d0
  248.             addi.w  #29,d0                  reposition the iconize gadget
  249.             moveq.w #11,d1                      the new height
  250.             move.l  #ImageIcon2a,d2
  251.             move.l  #ImageIcon2b,d3         supply the new gadget image
  252.             bsr.s   bar_gadg
  253.  
  254.             lea.l   Icondumm,a3                 plus the dummy...
  255.             bsr.s   bar_gadg
  256.  
  257.             lea.l   BordrHexpx,a3           deal with border structures
  258.             moveq.w #nrBs,d3                d3<-number of structures -1
  259.             moveq.l #bd_FrontPen,d4         d4<-structure offset
  260.             moveq.l #bd_BackPen,d5          d5<-ditto
  261.             moveq.l #BsLen,d6               d6<-structure size
  262.             bsr.s   scan_struc
  263.             lea.l   ITxtLng,a3              do the text structures
  264.             moveq.w #nrIs,d3
  265.             moveq.l #it_FrontPen,d4             regs as above
  266.             moveq.l #it_BackPen,d5
  267.             moveq.l #IsLen,d6
  268.             bsr.s   scan_struc
  269. .mc_ex:     movem.l (sp)+,a3-a4
  270.             rts
  271.  
  272.  
  273. scan_struc: lea.l   col_tab,a4              a4<-address of colour tab
  274.             move.w  d3,d7
  275. .nxtpen:    movea.l a3,a0
  276. .nxtstr:    movea.l a4,a1
  277.             moveq.w #3,d2                   d2<-number of colours
  278. .penloop:   move.w  (a1)+,d1
  279.             cmp.b   (a0,d4),d1
  280.             beq.s   .pen_found
  281.             dbra    d2,.penloop
  282. .pen_found: lsr.w   #8,d1
  283.             move.b  d1,(a0,d4)
  284. .bloop:     adda.w  d6,a0                   go to next structure
  285.             dbra    d3,.nxtstr
  286.             move.w  d5,d4                   change to bg pen
  287.             exg     d7,d3
  288.             cmp.w   d7,d3
  289.             bne.s   .nxtpen
  290. .bs_ex:     rts
  291.  
  292.  
  293. *****************************************************************************
  294. *
  295. *       Go and open a window in any case
  296. *           then iconize or de-iconize it
  297.  
  298.  
  299. put_windo:  movem.l a6,-(sp)
  300.             movea.l intuitionBase,a6        a6<-using intuition library
  301.             lea.l   RegNWindo,a0            a0<-holds newwindow address
  302.             bsr.s   copy_nw                 returns with windowptr in a4
  303.             move.l  d0,regwindow            store the window pointer
  304. .pw_ex:     movem.l (sp)+,a6
  305.             rts
  306.  
  307. copy_nw:    lea.l   newwin,a1               this is our newwindow struct
  308.             move.l  a1,a2
  309.             moveq.w #wstrucsz-1,d3          window structure size
  310. .copy:      move.b  (a0)+,(a1)+
  311.             dbra    d3,.copy
  312.             exg.l   a2,a0
  313.             jsr     _LVOOpenWindow(a6)
  314.             move.l  d0,a4                   a4<-from now holds windowptr
  315.             rts
  316.  
  317. wndw_icon:  movem.l a6,-(sp)
  318.             movea.l intuitionBase,a6        a6<-using intuition library
  319.             lea.l   RegNWindo,a0
  320.             bsr.s   close_win               close the window
  321.             moveq.l #0,d0
  322.             move.l  d0,regwindow                and clear it's pointer
  323.             lea.l   OpSizLong,a1            don't want feedback loops !!
  324.             move.l  d0,(a1)                 last gadget points to 0
  325.             lea.l   IconNWindo,a0           now open the icon window
  326.             bsr.s   copy_nw                 returns with windowptr in a4
  327.             move.l  d0,iconwindow           store the window pointer
  328. .iw_ex:     movem.l (sp)+,a6
  329.             rts
  330.  
  331. close_win:  move.w  wd_LeftEdge(a4),(a0)
  332.             move.w  wd_TopEdge(a4),nw_TopEdge(a0)   remember last pos
  333.             movea.l a4,a0
  334.             jsr     _LVOCloseWindow(a6)         close the window
  335.             rts
  336.  
  337. icon_close: movem.l a6,-(sp)
  338.             movea.l intuitionBase,a6        a6<-using intuition library
  339.             lea.l   IconNWindo,a0
  340.             bsr.s   close_win               close the window
  341.             clr.l   iconwindow
  342. .wi_ex:     movem.l (sp)+,a6
  343.             rts
  344.  
  345.  
  346. *****************************************************************************
  347. *
  348. *       Fill the window and draw a border
  349. *       input:      a4 <-window structure pointer
  350.  
  351. win_gfx:    movea.l gfxBase,a6              a6<-using grafix library
  352.             movea.l wd_RPort(a4),a1         get the window's rastport
  353.             move.w  wflood,d0
  354.             jsr     _LVOSetAPen(a6)         set fgpen
  355.             movea.l wd_RPort(a4),a1         get the window's rastport
  356.             moveq.l #4,d0
  357.             moveq.l #11,d1
  358.             move.l  #445,d2
  359.             moveq.l #71,d3
  360.             jsr     _LVORectFill(a6)        fill the window with colour 2
  361.             movea.l intuitionBase,a6        a6<-using intuition library
  362.             move.l  a4,a0                   get the window pointer
  363.             moveq.l #-1,d0
  364.             move.l  d0,a2                   leave Screen title, but
  365.             lea.l   regwindowtitle,a1           change the Window title
  366.             jsr     _LVOSetWindowTitles(a6)
  367.             movea.l wd_RPort(a4),a0         get the window's rastport
  368.             lea.l   ITxSStBit,a1            pick up the Status Bits text
  369.             moveq.l #0,d0                   relative X pos in window
  370.             moveq.l #0,d1                      "     Y pos
  371.             jsr     _LVOPrintIText(a6)
  372. .wg_ex:     rts
  373.  
  374.  
  375. *****************************************************************************
  376. *
  377. *       Put some graphics into the window
  378. *       inputs:     a4 <-window structure pointer or zero
  379.  
  380.  
  381. put_panel:  movem.l a6,-(sp)
  382.             bsr.s   win_gfx                 returns with intuiBase in a6
  383.             bsr     displ_val               put up hex and
  384.             bsr     disp_flag                              flags display
  385.  
  386.  
  387. *       add gadgets to window and make them visible
  388.  
  389.             lea.l   Icondumm,a1             remove dummy icon first
  390.             movea.l a4,a0
  391.             jsr     _LVORemoveGadget(a6)
  392.             move.l  wd_FirstGadget(a4),d6   d6<-address of window gads
  393.             movea.l a4,a0                   the window's pointer
  394.             lea.l   OpAbout,a1              pointer to gadget struct
  395.             lea.l   OpSizWord,a3
  396.             moveq.l #0,d2
  397.             add.b   op_size,d2              default = 0 = .W
  398.             neg.w   d2
  399.             muls.w  #gadstsiz,d2
  400.             adda.l  d2,a3
  401.             ori.w   #SELECTED,gg_Flags(a3)      word size on
  402.             moveq.l #0,d0                   start with first in list
  403.             moveq.l #-1,d1                          add all...
  404.             moveq.l #0,d2
  405.             move.l  d2,a2                   no requester...
  406.             jsr     _LVOAddGList(a6)        add all our updated gadgets
  407.             lea.l   OpSizLong,a1
  408.             move.l  d6,(a1)
  409.             lea.l   OpAbout,a3              pointer to gadget struct
  410.             moveq.l #-1,d0                      all gadgets...
  411.             bsr     gad_refrsh
  412. .gfx_ex:    movem.l (sp)+,a6
  413.             rts
  414.  
  415.  
  416. *****************************************************************************
  417.  
  418.                 include     regsub.s
  419.                 include     reggds.s
  420.                 include     reggfx.s
  421.  
  422. *****************************************************************************
  423.  
  424.                 even
  425.  
  426.                 section     regivars,DATA
  427.  
  428. RegNWindo:      dc.w    9                   nw_LeftEdge
  429.                 dc.w    66                  nw_TopEdge
  430.                 dc.w    448                 nw_Width
  431.                 dc.w    73                  nw_Height
  432.                 dc.b    -1                  nw_DetailPen
  433.                 dc.b    -1                  nw_BlockPen
  434.                 dc.l    regwinflgs          nw_IDCMPFlags
  435.                 dc.l    regiflags           nw_Flags
  436.                 dc.l    Icondumm            nw_FirstGadget
  437.                 dc.l    0
  438.                 dc.l    regwindowtitle      nw_Title
  439.                 dc.l    0                   nw_Screen
  440.                 dc.l    0                   nw_BitMap
  441.                 dc.w    0                   nw_MinWidth
  442.                 dc.w    0                   nw_MinHeight
  443.                 dc.w    0                   nw_MaxWidth
  444.                 dc.w    0                   nw_MaxHeight
  445.                 dc.w    WBENCHSCREEN        nw_Type
  446.                 even
  447. regwindowtitle: dc.b    'A68k Data Register Processor',0
  448.                 even
  449.  
  450. IconNWindo:     dc.w    0,0,56,10
  451.                 dc.b    1,2
  452.                 dc.l    MOUSEBUTTONS
  453.                 dc.l    iconflags
  454.                 dc.l    0,0
  455.                 dc.l    ic_Title
  456.                 dc.l    0,0
  457.                 dc.w    0,0,0,0,WBENCHSCREEN
  458.                 even
  459. ic_Title:       dc.b    '_DReg_',0
  460.                 even
  461.  
  462. wflood:         dc.w    2
  463. gadsw:          dc.w    0
  464. col_tab:        dc.b    1,0,2,1,0,2,3,3
  465.                 dc.b    0,0
  466.                 even
  467.  
  468. gfxBase:        dc.l    0                   library pointers
  469. intuitionBase:  dc.l    0
  470.  
  471. regwindow:      dc.l    0                   pointers to Window structures
  472. iconwindow:     dc.l    0
  473. regRequest:     dc.l    0                   Requester structure pointer
  474.  
  475. registerd0:     dc.l    0
  476. registerd1:     dc.l    0                   register contents
  477. registerd2:     dc.l    0
  478. registerd3:     dc.l    0
  479. oldsrcreg:      dc.l    0
  480. rawstuff:       dc.l    0
  481.  
  482. regselect:      dc.l    TxtRd0
  483.                 dc.l    TxtRd1              register select list
  484.                 dc.l    TxtRd2
  485.                 dc.l    TxtRd3
  486. regend:         dc.l    registerd0
  487.                 dc.l    registerd1
  488.                 dc.l    registerd2
  489.                 dc.l    registerd3
  490.  
  491. sourcinput:     dc.l    registerd0          the active source and
  492. destinput:      dc.l    registerd1               destination registers
  493. condcodes:      dc.w    0
  494.                 dc.w    0
  495. dispsel:        dc.w    0                   display switch
  496. HexDec:         dc.b    'HEX',0,'DEC',0         strings for HEX or DEC
  497. hex_array:      dc.b    '0123456789ABCDEF',0
  498. op_size:        dc.b    0,0
  499.  
  500.                 even
  501. gfxname:        dc.b    'graphics.library',0
  502.                 even
  503. intuiname:      dc.b    'intuition.library',0
  504.                 even
  505. newwin:         ds.b    128
  506.  
  507. verstring:      dc.b    '$VER: DReg 1.21 (01/02/1999) Copyright © stranded ufo',0
  508.                 dc.b    0,0
  509. sajt:           dc.b    'B-Q',0
  510.                 even
  511.  
  512.  
  513. *****************************************************************************
  514. *
  515. *           E Q U A T E S
  516.  
  517.  
  518. _SysBase        equ     $00000004
  519.  
  520. reqsize         equ     rq_SIZEOF
  521. wstrucsz        equ     IconNWindo-RegNWindo
  522. regoff          equ     regend-regselect
  523. numregs         equ     regoff/4
  524.  
  525. regiflags1      equ     WINDOWDRAG+SMART_REFRESH+RMBTRAP+NOCAREREFRESH
  526. regiflags2      equ     WINDOWDEPTH+WINDOWCLOSE
  527. regiflags3      equ     WBENCHWINDOW                      +ACTIVATE
  528. regiflags       equ     regiflags1+regiflags2+regiflags3
  529. regwinflgs      equ     CLOSEWINDOW+GADGETDOWN+GADGETUP+REQVERIFY
  530.  
  531. iconflags       equ     regiflags1
  532.  
  533. bitflags        equ     GADGIMAGE+GADGHIMAGE
  534. bitactiv        equ     TOGGLESELECT+GADGIMMEDIATE
  535. opactiv         equ     RELVERIFY
  536.  
  537.                 END
  538.  
  539.  
  540. *****************************************************************************
  541.  
  542.  
  543.  
  544.  
  545.